﻿//Intend to invoke using the Object Contractor Invocation Pattern
var City = function (name, location) {
    //arguments
    this.name = name;
    this.location = location;
}

//Use the new keyword to create a new object with a name and location property
var denver = new City("Denver", "18.9");
var houston = new City("Houston", "32.4");

City.prototype.display = function () {
    return this.name + ' is located at: ' + this.location;
}

var austin = Object.create(City.prototype);
austin.name = "Austin";
austin.location = "376423";
alert(austin.display());


//City.__proto__ = Function Prototype.__proto__ = Object Prototype
//City.prototype = { name: name, location: location, display: function }




function Destinations(places) {
    this.places = places;
}

Destinations.prototype.display = function () {
    var str = "";
    for (var i = 0; i < this.places.length; i++)
        str += this.places[i].display() + " ";
    return str;
};


var myDestination = new Destinations([
    new City("Austin", "30.2500° N, 97.7500° W"),
    new City("Vegas", "36.1215° N, 115.1739° W"),
    new City("Mumbai", "18.9750° N, 72.8258° E")
]);

//alert(myDestination.display());


